<?php
// no direct access
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
?>
<?php if ($type == 'login') : ?>

<script type="text/javascript">
    $(document).ready(function() {

        var trigger = $('#login-trigger'),
            loginBar = $('#login-bar'),
            cls = 'clickedLoginTrigger',
            closed = false;

        function show()
        {
            trigger.addClass(cls);
            loginBar.slideDown();
        }

        function hide()
        {
            loginBar.fadeOut();
            trigger.removeClass(cls);
        }

        trigger.click(function()
        {
            show();
        });

        $('.close', loginBar).click(function()
        {
            hide();
            closed = true;
        });

        show();
        loginBar.addClass('auto-opened');
        window.setTimeout(function()
        {
            if (!closed)
            {
                hide();
            }
        }, 100 * 1000);
    });
</script>

<ul id="top-menu">
    <li>
        <a href="<?php echo JRoute::_('index.php?option=com_users&view=registration'); ?>">
        zarejestruj</a>
    </li>
    <li><a id="login-trigger" href="#">zaloguj się</a></li>
</ul>
<form method="post" action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" id="login-bar">
    <span class="close">x</span>
    <input type="text" name="username" id="login" class="login-input" />
    <input type="password" name="password" id="password" class="login-input" />
    <label><input type="checkbox" name="remember" value="yes" /> zapamiętaj mnie </label>
    <a href="<?php echo JRoute::_('index.php?option=com_users&view=remind'); ?>" id="password-reminder"/>zapomniałem hasła</a>
    <input type="submit" name="Submit" id="submit" value="zaloguj" />
    <input type="hidden" name="option" value="com_users" />
    <input type="hidden" name="task" value="user.login" />
    <input type="hidden" name="return" value="aW5kZXgucGhwP2" />
    <?php echo JHtml::_('form.token'); ?>
</form>

<?php else : ?>
<ul id="top-menu">
    <li>
        <form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" id="login-form">
            <input type="submit" name="Submit" class="button" value="wyloguj (<?php echo htmlspecialchars($user->get('username')); ?>)" />
            <input type="hidden" name="option" value="com_users" />
            <input type="hidden" name="task" value="user.logout" />
            <input type="hidden" name="return" value="<?php echo $return; ?>" />
            <?php echo JHtml::_('form.token'); ?>
        </form>
    </li>
    <li><a id="login-trigger" href="#">dodaj artykuł</a></li>
    <li><a href="#">moje konto</a></li>
</ul>
<?php endif; ?>
